package com.jsnj33.pdaproject.utils;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class TestInfo {


    public static void main(String[] args) {
        ArrayList lit = new ArrayList<>();
        lit.add("哈殴");
        lit.add("哈殴");
        lit.add("哈殴");
        Map map = new HashMap<>();
        map.put("lihao", "你好");
        map.put("bucuo", lit);
//        System.out.println(mapToString(map));
        System.out.println(new Gson().toJson(map));

    }

    public static String mapToString(Map<String, Object> map) {
        if (map == null) {
            return "{}";
        }
        StringBuffer sb = new StringBuffer();
        sb.append("{ ");
        for (String s : map.keySet()) {
            sb.append("\"" + s + "\":\"" + map.get(s) + "\",");
        }
        sb.replace(sb.length() - 1, sb.length(), "}");
        return sb.toString();
    }

}
